package rpc

import (
	. "leaf/core/error"
	"leaf/core/log"
	. "leaf/core/msg"
	"leaf/pb"
	"leaf/server/match/service"
)

func Rpc_StartMatch(s interface{}, msg *PMsg) *Error {
	log.Release("Rpc_StartMatch...")
	c2s := msg.C2S().(*pb.L2M_StartMatch)

	if c2s.User == nil {
		return Error_MsgError
	}

	var err = s.(*service.MatchService).StartMatch(c2s.GetType(), c2s.GetUser())
	if err != nil {
		return err
	}

	s2c := msg.C2S().(*pb.M2L_StartMatch)
	s2c.Type = c2s.Type

	return nil
}
